@extends('Admin.layouts.common')

@section('content')
    <div class="container myContainer">
        <button class="btn btn-info searchBtn" onclick="$('.search_box').slideToggle();">搜索/筛选</button>
        <div class="search_box">
            <form id="search_form" method="GET">
               
                <label>
                    订单号：<br>
                    <input name="order_no" type="text" class="form-control search_form_control" value="{{ $_search['order_no']??'' }}">
                </label>
                
                <label>
                    支付：<br>
                    <select name="pay_status" class="form-control search_form_control">
                        <option value="">全部</option>
                        @foreach($order_pay_status as $key=>$val)
                        <option value="{{$key}}" @if(isset($_search['pay_status']) && $_search['pay_status']==$key) selected="" @endif>{{$val}}</option>
                        @endforeach
                    </select>
                </label>
                <label>
                    发货：<br>
                    <select name="ship_status" class="form-control search_form_control">
                        <option value="">全部</option>
                        @foreach($order_ship_status as $key=>$val)
                        <option value="{{$key}}" @if( isset($_search['ship_status']) && $_search['ship_status']==$key) selected="" @endif>{{$val}}</option>
                        @endforeach
                    </select>
                </label>
                <button class="btn btn-primary" type="submit">&nbsp;&nbsp;确定&nbsp;&nbsp;</button>
            </form>
        </div>

        <div id="order_tag"></div>

        <div class="table-responsive">
            <table class="table">
                <caption>订单列表</caption>
                <thead>
                    <tr>
                        <th>Uid</th>
                        <th>订单号</th>
                        <th>昵称</th>
                        <th>标题</th>
                        <th>金额</th>
                        <th>支付状态</th>
                        <th>发货状态</th>
                        <th>添加时间</th>
                        
                        <th>操作</th>
                    </tr>
                </thead>
                <tbody>
                    @forelse($list->items() as $item)
                        <tr id="tr_{{$item->id}}">
                            <td>{{ $item->uid }}</td>
                            <td>
                                {{ $item->order_no }}<br/>
    
                            </td>
                            <td>{{ urldecode($item->user->nickname) }}</td>
                            <td>
                                @foreach($item->product as $p)
                                <div style="width:150px;">
                                <img style="max-width: 100px; float: left;" src="{{img($p->thumb_img)}}">
                                </div>
                                <div style="float: left; width: 190px; padding: 5px; font-size: 12px">
                                <p>{{$p->product_name}} </p>
                                <span>{{$p->attr}}</span><br/>
                                </div>
                                @endforeach
                            </td>
                            <td>{{$item->amount}}</td>
                            <td>{{$item->pay_status_text}}</td>
                            <td>{{$item->ship_status_text}}</td>
                            <td>{{ date('Y/m/d H:i:s',$item->add_time) }}</td>
                            <td>
                                <a href="/order/detail/{{ $item->id }}">编辑</a>
                                
                            </td>
                        </tr>
                    @empty
                        <tr><td class="text-center" colspan="7">没有数据</td></tr>
                    @endforelse
                </tbody>
            </table>
            <div class="text-center">
                {{ $list->links() }}
            </div>
        </div>

    </div>
@endsection

@section('foot')
<script type="text/javascript">
$.ajaxSetup({
    headers: {
    'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
    }
})

function ajax_delete_theme(id){
    if(confirm('确认删除吗?')){
        $.post("/theme/ajax_delete_theme/"+id,{},function(json){
            if(json.status==1){
                $("#tr_"+json.data).fadeOut();
            }else{
                alert(json.info);
            }
        },"json");
    }
}
</script>
@endsection